package com.example.github.io.stream.buffer;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class BufferedInputStreamExample {
    public static void main(String[] args) {
        // 1. 创建 FileInputStream 对象实例 fileInputStream
        // 2. 把 fileInputStream 传给 BufferedInputStream 类生成对应实例对象
        // 3. 读取流信息输出
        // 4. 关闭流
        try {
            FileInputStream fileInputStream = new FileInputStream("D:/logs/test.txt");
            BufferedInputStream bis = new BufferedInputStream(fileInputStream);
            int i;
            while ((i=bis.read()) != -1) {
                System.out.print((char)i);
            }
            System.out.println();
            System.out.println("success ...");
            bis.close();
            fileInputStream.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
